<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登陆</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://at.alicdn.com/t/font_835526_kx07n4ng8w8.css">
    <link rel="stylesheet" href="./css/Initialization.css">
    <link rel="stylesheet" href="./css/commen.css">
    <link rel="stylesheet" href="./css/login1111.css">
    <link rel="shortcut icon" href="../../imgs/bitbug_favicon.ico" type="image/x-icon">
</head>
<body>
<div class="login container">
    <div class="center">
        <!-- <div class="leftinfo">
            <img src="./imgs/1572951588(1).jpg" alt="">
            <span>北京联合大学</span>
            <span>国际商务综合实训系统</span>
        </div>
        <div class="rightinfo">

        </div> -->
        <div class="surelogin boxshowlogin">
            <div class="loginheader">
                <img src="./imgs/1573231164(1).jpg" alt="">
                <span>北京联合大学国际商务综合实训系统</span>
            </div>
            <div class="input">
                <!-- <i class="iconfont icon-user"></i> -->
                <img src="./imgs/person.png" alt="">
                <span>账号</span>
                <input type="text" name="username" id="username" placeholder="请输入账号名称">
            </div>
            <div class="input">
                <!-- <i class="iconfont icon-suo1"></i> -->
                <img src="./imgs/password.png" alt="">
                <span>密码</span>
                <input name="password" id="password" placeholder="请输入账号密码" type='password'>
            </div>
            <div class="input yaninput">
                <!-- <i class="iconfont icon-anquan"></i> -->
                <img src="./imgs/ma.png" alt="">
                <span>验证码</span>
                <input type="text" name="tCode" id="tCode" placeholder="验证码">
                <div class="number"><img id="numimg" src="verificationcode" onclick="changeImg()" style="width: 55px;height: 34px;"/></div>
                <i class="iconfont icon-shuaxin" onclick="changeImg()"></i>
            </div>
            <div class="button" id="subBut">登陆</div>
        </div>
    </div>
</div>
<script src="./js/jquery-3.4.1.min.js"></script>
<script src="./js/commen.js"></script>
<script>
    //校验图片
    function changeImg(){
        $("#numimg").attr("src","../verificationcode?"+Math.random());
    }

    $(function(){
        $("#tCode").keypress(function() {
            console.log("123")
            if (event.keyCode == "13") {//keyCode=13是回车键
                $('#subBut').click();
            }
        });

        $("#subBut").click(function(){
            var username = $("#username").val();
            var password = $("#password").val();
            var tCode = $("#tCode").val();

            if(username.length == 0){
                $("#username").focus();
                alert("请输入用户名");
                return false;
            }
            if(password.length == 0){
                $("#password").focus();
                alert("请输入密码");
                return false;
            }
            if(tCode.length == 0){
                $("#tCode").focus();
                alert("请输入验证码");
                return false;
            }
            $.ajax({
                type : "POST",
                url : "tologin",
                data : {username: username, password: password, tCode:tCode},
                dataType : "json",
                success : function(json) {
                    if(json.state == error){
                        alert(json.result);
                        changeImg();
                    }else{
                        location.href="../function/index";
                    }
                },
                error:function(msg){
                    alert("程序出错，请联系管理员");
                }
            });
        });
    })
</script>
</body>
</html>
